/*
	选择组件--科目选择用ajax程序
*/
var objRequest,action,method,formcontent,vid,path,f_divId;
function ajaxInit() {
	try {
		objRequest = new ActiveXObject("Microsoft.XMLHTTP");
	} catch(e)
	 {
		try { 
			objRequest = new ActiveXObject("Msxml2.XMLHTTP");        
		} catch(ex)
	 	{ 
		try {
			objRequest = new XMLHttpRequest();
			} catch(exc) {
				alert("浏览器不支持Ajax，可能会导致某些功能不能使用！");         
				objRequest = false;
			}
		}
	}
}
function ajaxProcessBase(tid,tjs,pid){ 
var imgObj = document.getElementById("img"+tid);
var imgObjt = document.getElementById("imgt"+tid);
var imgsrc = imgObj.src;
if(imgsrc.indexOf("close1.gif")>2){
ajaxInit();
vid=tid;
if(type=='bm'){
	action=path+'addDepartment.do';method='post';formcontent="method=creatTreeSelect&type=bm&treeid="+tid+"&js="+tjs+"&pid="+pid;
}
if(type=='bms'){
	action=path+'addDepartment.do';method='post';formcontent="method=creatTreeSelect&type=bms&treeid="+tid+"&js="+tjs+"&pid="+pid;
}
if(type=='model'){
	action=path+'addModel.do';method='post';formcontent="method=creatTreeSelect&treeid="+tid+"&js="+tjs+"&pid="+pid;
}	
if(type=='role'){
	action=path+'addRole.do';method='post';formcontent="method=creatTreeSelect&treeid="+tid+"&js="+tjs+"&pid="+pid;
}
if(type=='user'){
	action=path+'addDepartment.do';method='post';formcontent="method=creatTreeSelect&type=user&rname="+roleName+"&treeid="+tid+"&js="+tjs+"&pid="+pid;
}	
if(type=='user_bm_o'){
	action=path+'addDepartment.do';method='post';formcontent="method=creatTreeSelect&type=user_bm_o&treeid="+tid+"&js="+tjs+"&pid="+pid;
}	
if(type=='user_bm_n'){
	action=path+'addDepartment.do';method='post';formcontent="method=creatTreeSelect&type=user_bm_n&treeid="+tid+"&js="+tjs+"&pid="+pid;
}	
if(objRequest){ 
	objRequest.open(method, action, true); 
	objRequest.onreadystatechange = dealOrgUser;   
	if(method == "post"){ 
		objRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	}   
	formcontent = formcontent != "" ? formcontent : null; 
	objRequest.send(formcontent);      
	action = "";method = "";formcontent = "";
	imgObj.src="images/open.gif";
	if(imgObjt!=null){
		imgObjt.src="images/minus.gif";
	}
	}
}else{
	document.getElementById(tid).innerHTML="<span style='font-size: 1px;color: #FFFFFF;'>.</span>";
	action = "";method = "";formcontent = "";
	imgObj.src="images/close1.gif";
	if(imgObjt!=null){
		imgObjt.src="images/plus.gif";
	}
}

}
function isAjax() {
	if(objRequest.readyState == 4){
	if(objRequest.status == 200)
	{ 
		return true;
	} 
	else {
		alert("Problem: "+objRequest.statusText);
	}          
	}return false;
}  

function dealOrgUser(){
	if(isAjax()){  
		arr="";
		document.getElementById(vid).innerHTML=objRequest.responseText;
		objRequest.abort();
		objRequest = null;
		vid="";
	}
}
function selectTree(aid,aname){
	window.parent.document.getElementById(iid).value=aid;
	window.parent.document.getElementById(iname).value=aname;
}
var iddemp = "";
var namedemp = "";
function selectTrees(aid,aname){
if(iddemp.indexOf(aid)<0){
	iddemp = iddemp +","+aid;
	namedemp = namedemp +"  "+aname;
	window.parent.document.getElementById(iid).value=iddemp;
	window.parent.document.getElementById(iname).value=namedemp;
}
}

function ajaxProcessBaseZ(){ 
var js_t = document.getElementById("js").value;
var f_divId_t=document.getElementById("f_divId").value;
var  aid_t = document.getElementById("aid").value;
var my_div=document.getElementById("my_div").value;
ajaxInit();

action=path+'addDepartment.do';method='post';formcontent="method=creatTreeSelect&treeid="+f_divId_t+"&js="+js_t+"&pid="+aid_t;
if(objRequest){ 
	objRequest.open(method, action, true); 
	objRequest.onreadystatechange = dealOrgUser;   
	if(method == "post"){ 
		objRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	}   
	formcontent = formcontent != "" ? formcontent : null; 
	objRequest.send(formcontent);      
	action = "";method = "";formcontent = "";
	}
}